Skip to content

fix(blob): respect server pathname in handleUpload#1043

Open
matingathani wants to merge 2 commits intovercel:mainfrom
matingathani:fix/blob-handle-upload-pathname
Open

fix(blob): respect server pathname in handleUpload#1043
matingathani wants to merge 2 commits intovercel:mainfrom
matingathani:fix/blob-handle-upload-pathname

Conversation

@matingathani
Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings April 2, 2026 21:50
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 2, 2026

@matingathani is attempting to deploy a commit to the Curated Tests - Permanent E2E Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 2, 2026

🦋 Changeset detected

Latest commit: f4e2dc6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@vercel/blob Patch
vercel-storage-integration-test-suite Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes handleUpload() so that when onBeforeGenerateToken() returns an overridden pathname, that server-controlled pathname is used when generating the client token.

Changes:

  • Update handleUpload() to prefer a pathname returned from onBeforeGenerateToken() when generating the client token.
  • Add a Node test covering pathname override behavior in generated client tokens.
  • Add a changeset documenting the patch change for @vercel/blob.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/blob/src/client.ts Uses server-returned pathname override when generating the client token in handleUpload().
packages/blob/src/client.node.test.ts Adds regression test asserting the overridden pathname is embedded in the generated client token.
.changeset/fix-blob-handle-upload-pathname.md Documents the behavior change as a patch release.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +595 to +599
const {
callbackUrl: providedCallbackUrl,
pathname: overriddenPathname,
...tokenOptions
} = payload;
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

payload is typed as the return value of onBeforeGenerateToken, but HandleUploadOptions['onBeforeGenerateToken'] currently does not include a pathname field in its return type (see packages/blob/src/client.ts around the HandleUploadOptions definition). Destructuring pathname: overriddenPathname here (and returning { pathname: ... } in tests/user code) will fail TypeScript type-checking. Update the onBeforeGenerateToken return type to allow an optional pathname override (and ideally document it) so this change is type-safe.

Copilot uses AI. Check for mistakes.
@matingathani
Copy link
Copy Markdown
Contributor Author

Addressed the type-safety gap here. onBeforeGenerateToken now explicitly allows an optional pathname override in its return type, so the implementation and test coverage are aligned with the public type surface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants